// 判断该页面是否允许被分享
import {mapGetters} from 'vuex'
export default {
	data() {
		return {
			// 未登录验证
			loginList: [
				{src: 'pagesA/storeList/storeList', name: '我的门店'},
				{src: 'pagesA/storeList/storeDetail', name: '编辑门店'},
				{src: 'pagesA/storePeople/storePeople', name: '人员管理'},
				{src: 'pagesA/storeLarpManager/storeLarpManager', name: '组局管理'},
				{src: 'pagesA/teamOrder/teamOrder', name: '组局订单'},
				{src: 'pagesA/storeIncomeStatistics/storeIncomeStatistics', name: '收益统计'},
				{src: 'pagesA/larpManager/larpManager', name: '我的剧本'},
				{src: 'pagesA/storeAddLarp/storeAddLarp', name: '剧本库'},
				{src: 'pagesA/afterSale/afterSale', name: '售后管理'},
				{src: 'pagesA/exhibitList/exhibitList', name: '切换展会'},
				{src: 'pagesA/want/want', name: '我的意向'},
				{src: 'pagesA/replyManager/replyManager', name: '我的评测'},
				{src: 'pagesA/like/like', name: '我的偏好'},
				{src: 'pagesA/storeReply/storeReply', name: '评价管理'},
				{src: 'pagesA/userSubmit/userSubmit', name: '意见反馈'},
				{src: 'pagesB/address/address', name: '收货地址'},
				{src: 'pagesA/setting/setting', name: '门店设置'},
				{src: 'pagesB/accout/accout', name: '账号设置'},
				{src: 'pagesA/want/setting', name: '提交意向'},
				{src: 'pagesA/order/order', name: '订单'},
				{src: 'pages/carTime/carTime', name: '测本'},
				{src: 'pages/carTime/gameList', name: '测本'},
				{src: 'pages/carTime/gameTime', name: '测本'},
			],
			// 验证是否入驻了平台
			planformList: [
				{src: 'pagesA/storeList/storeList', name: '我的门店'},
				{src: 'pagesA/storeList/storeDetail', name: '编辑门店'},
				{src: 'pagesA/storePeople/storePeople', name: '人员管理'},
				{src: 'pagesA/storeLarpManager/storeLarpManager', name: '组局管理'},
				{src: 'pagesA/larpManager/larpManager', name: '剧本管理'},
				{src: 'pagesA/teamOrder/teamOrder', name: '组局订单'},
				{src: 'pagesA/replyManager/replyManager', name: '评价管理'},
				{src: 'pagesA/storeIncomeStatistics/storeIncomeStatistics', name: '收益统计'},
				{src: 'pagesA/storeAddLarp/storeAddLarp', name: '剧本库'},
				{src: 'pagesA/afterSale/afterSale', name: '售后管理'},
				{src: 'pagesA/storeReply/storeReply', name: '评价管理'},
				{src: 'pagesB/address/address', name: '收货地址'},
				{src: 'pagesA/authPage/authPage', name: '认证'},
				{src: 'pagesA/goodsManager/goodsManager', name: '商城管理'},
				{src: 'pagesA/issueIncomeStatistics/issueIncomeStatistics', name: '收益管理'},
				{src: 'pagesA/order/order', name: '订单'},
				{src: 'pagesA/addLarp/addLarp', name: '添加剧本'},
				{src: 'pagesA/experienceStoreManager/experienceStoreManager', name: '体验商城管理'},
				{src: 'pagesA/returnBackManager/returnBackManager', name: '退回管理'},
			],
			// 验证是否认证
			userAuthenList: [
				{src: 'pagesA/larpManager/larpManager', name: '剧本管理'},
				{src: 'pagesA/storeList/storeList', name: '我的门店'},
				{src: 'pagesA/goodsManager/goodsManager', name: '商城管理'},
				{src: 'pagesA/storeList/storeDetail', name: '编辑门店'},
				{src: 'pagesA/order/order', name: '订单',type: 2},
				{src: 'pagesA/storeReply/storeReply', name: '评价管理'},
				{src: 'pagesA/storePeople/storePeople', name: '人员管理'},
				{src: 'pagesA/storeLarpManager/storeLarpManager', name: '组局管理'},
				{src: 'pagesA/teamOrder/teamOrder', name: '组局订单'},
				{src: 'pagesA/storeIncomeStatistics/storeIncomeStatistics', name: '收益统计'},
				{src: 'pagesA/afterSale/afterSale', name: '售后管理',type: 2},
				{src: 'pagesA/experienceStoreManager/experienceStoreManager', name: '体验商城管理'},
				{src: 'pagesA/returnBackManager/returnBackManager', name: '退回管理'},

			],
			// 验票
			isBillList: [
				{src: 'pagesA/larpSetting/larpSetting', name: '参展信息'},
				{src: 'pagesA/goonLarpManager/goonLarpManager', name: '发车管理'},
				{src: 'pagesA/want/want', name: '我的意向'},
				{src: 'pagesA/replyManager/replyManager', name: '我的评测'},
				{src: 'pagesA/like/like', name: '我的偏好'},
			],
		}

	},
	computed: {
		...mapGetters(['loginForm'])
	},
	methods:{
		valiDateMixin(type,msg){
			if(this.loginForm.userType!==type){
				uni.showModal({
					showCancel:false,
					title:'温馨提示',
					content:msg || '这里不是你该来的地方',
					confirmText:'去首页',
					success:()=> {
						this.$u.route({
							type:"reLaunch",
							url:"/pages/index/index"
						})
					}
				})
			}
		},
		// 分享后用户类型验证
		shareUserType(type){
			if(type == 'issue' && this.userType == 'store'){
				this.valiDateMixin(type,'您的身份是属于店家端，无权限访问发行端')
			}
			if(type == 'store' && this.userType == 'issue'){
				this.valiDateMixin(type,'您的身份是发行，无权限访问店家端')
			}
		},
		shareLogin(url,type){
			let src = this.loginList.find(res=>res.src === url).src
			// 分享后进入需要登录的页面提示登录
			if(url === src && !this.loginForm.uid){
				this.loginValidate(false)
				return false
			}
			if(this.loginForm.uid){
				this.shareUserType(type)
				return false
			}
			let planSrc = this.planformList.find(res => res.src === url).src
			// 分享后进入需要入驻验证是否入驻了平台
			if(url === planSrc && this.loginForm.uid && this.loginForm.enterOperationStep!==2){
				this.planformValidate(false)
				return false
			}
			// 分享后进入需要入驻验证是否已认证
			let userAuthen = this.userAuthenList.find(res => res.src === url)
			if(url === userAuthen.src && this.loginForm.uid && this.loginForm.userAuthenticate !== 2  ){
				this.userAuthenticateValidate(false) //未认证弹框
				return false;
			}
			// 分享后进入需要验票
			if(url === userAuthen && this.loginForm.uid && [1,2].includes(this.loginForm.exhibitOperationStep)){
				this.isBillVaildate(false) //验票
				return false;
			}
		}
	},
	onShareAppMessage() {
		let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
		let curRoute = routes[routes.length - 1].route //获取当前页面路由
		let curParam = routes[routes.length - 1].options; //获取路由参数
		// let param = ''
		// for (let key in curParam) {
		// 	param += '?' + key + '=' + curParam[key]
		// }
		if(curRoute !== '/pages/index/index'){
			return {
				title: '',
				path: `/pages/index/index?src=${curRoute}&param=${JSON.stringify(curParam)}&userType=${this.loginForm.userType}`
			}
		}

	}
}